#pragma once

#include <iostream>

#define Conv(v) (struct sockaddr *)(v)
#define Die(n)   \
    do           \
    {            \
        exit(n); \
    } while (0)

enum 
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    SENDTO_ERR,
    RECV_ERR
};

bool SplitString(const std::string& str,std::string* A,std::string* B,const std::string& gap)
{
    auto pos = str.find(gap);
    if(pos == std::string::npos) return false;
    *A = str.substr(0,pos);
    *B = str.substr(pos+gap.size());
    if(A->empty() || B->empty()) return false;
    return true;
}